package com.fenghongzhang.login.mvp.view;

import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.fenghongzhang.lib.mvp.view.BaseActivity;
import com.fenghongzhang.login.R;
import com.fenghongzhang.login.mvp.contract.UserContract;
import com.fenghongzhang.login.mvp.model.UserModel;
import com.fenghongzhang.login.mvp.presenter.UserPresenter;

public class MainActivity extends BaseActivity<UserPresenter> implements UserContract.IUserView {

    private EditText name;
    private EditText pwd;
    private Button login;
    @Override
    public int bindLayout() {
        return R.layout.activity_main;
    }

    @Override
    public void initView() {
        name = (EditText) findViewById(R.id.name);
        pwd = (EditText) findViewById(R.id.pwd);
        login = (Button) findViewById(R.id.login);
    }

    @Override
    public void initData() {

        mPresenter = new UserPresenter(new UserModel(),this);

        login.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String name = getName();
                String pwd = getPwd();
                mPresenter.login(name,pwd);
            }
        });
    }

    @Override
    public String getName() {
        return name.getText().toString();
    }

    @Override
    public String getPwd() {
        return pwd.getText().toString();
    }


}
